﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data.SqlClient;

public partial class Admin_tintuc : System.Web.UI.Page
{
    private void reset()
    {
        txtnoidung.Text = "";
        txtnoidungtomtat.Text = "";
        txttieude.Text = "";
    }

    protected void btnxoa_Click(object sender, EventArgs e)
    {
        reset();
    }
    protected void btnthem_Click(object sender, EventArgs e)
    {
        try
        {
            String sql = String.Format("insert into tintuc(tieude,noidungtomtat,noidung,ngaydang)  values('{0}','{1}','{2}','{3}')",
                txttieude.Text, txtnoidungtomtat.Text, txtnoidung.Text, Calendar1.SelectedDate.ToString("MM/dd/yyyy"));

            SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            con.Open();
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.ExecuteNonQuery();
            con.Close();
            reset();
            GridView1.DataBind();
        }
        catch (Exception)
        {
            Response.Write("<script>alert('Khong the them du lieu')</script>");
        }
    }

    
}
